package com.lc.lc474;

public class Main {

}

class Solution {
    int a, b;
    void getNum(String str) {
    	a = b = 0;
        char[] arr = str.toCharArray();
        for (int i = 0; i < str.length(); i ++) {
            if (arr[i] == '0' ) {
            	a ++;
            } else {
            	b ++;
            }
        }
    }
    public int findMaxForm(String[] strs, int m, int n) {
        int len = strs.length;
        int[][] dp = new int[m + 1][n + 1];

        for (int i = 0; i < len; i ++) {
            getNum(strs[i]);
            for (int j = m; j >= a; j --) {
            	for (int k = m; k >= b; k --) {
            		dp[j][k] = Math.max(dp[j][k], dp[j - a][k - b] + 1);
            	}
            }
        }

        return dp[m][n];
    }
}